import java.util.Scanner;
import java.util.Stack;
// 注意类名必须为 Main, 不要有任何 package xxx 信息

public class Main {
    static class TreeNode {
        public TreeNode left ;
        public TreeNode right ;
        char val;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        TreeNode root = new Main().CreateTree(s);
        MidErg(root);
        int[] arr = new int[]{1 ,2 , 4};
        System.out.println(arr.length);
        }
    int i = 0;
    public TreeNode CreateTree(String s) {
        if(s.length() == i){
            return null;
        }
        else{
            Character s1 = s.charAt(i);
            if(s1.equals('#')){
                return null;
            }else{
                TreeNode root = new TreeNode();
                root.val = s.charAt(i);
                i++;
                root.left = CreateTree(s);
                i++;
                root.right = CreateTree(s);
                return root;
            }

        }
    }
    public static void MidErg(TreeNode root){
        if(root == null){
            return;
        }
        MidErg(root.left);
        System.out.print(root.val+ " ");
        MidErg(root.right);
    }
}